DebugStr breakpoints are useful for debugging, but sometimes you need to debug code that goes through a thousand or a million breakpoints before the error occurs.
This happened to me when I was writing an AppleTalk adev to drive Metricom radio network interfaces. My code seemed to work, but after working fine for a few minutes, the packets would suddenly stop getting through. There seemed to be no pattern to it. It was a mystery.
By using the event logger to record all the packets I sent and received, I could look at the log afterwards to see what had happened. It turned out that if the AppleTalk packet contained a letter "a" followed by a "/" character, then it would trigger the radio’s modem emulation code to wake up and think that you wanted it to repeat the last Hayes AT command in the middle of this packet! ("A/" is the Hayes shortcut meaning “repeat last command”). I don’t know how I would have ever discovered that bug without the event logger. (If you’re using Metricom radios, don’t worry, this "A/" bug is fixed now.)
How to use the Event Logger
Declare an EventLog object for each log file you want to write.
Call EventLog_Open(EventLog *e, u_char *fileName) to initialise the object and create the log file in the System Folder.
Call logevent(EventLog *e, char *format, ...) to write a timestamped message to the log file. The format string works like C’s printf function. If you have multiple lines to write, and they don’t each need a separate timestamp, you can call logsuppliment(EventLog *e, char *format, ...) to write those additional lines.
Call logdata(EventLog *e, char *desc, void *data, u_short length, u_short limit) to write hex data to the log. If the length of the block of data (length) is greater than the maximum you specify (limit), then only the first 'limit' bytes are written.
Note: Timestamps are relative to the last event (i.e. they record the interval between events). They do not record the absolute time of day.